<?php 
if($division_id == 1)
{
    $title = "Uda Palatha";
} else if($division_id == 2) {
    $title = "Doluwa";
}
?>
<div class="article2">
    <?php $this->load->view("topsearch"); ?>
</div><!-- Search by Category end -->

<!-- Page Navigation start-->
<div id="page-navi">Population Statistics - <?php echo $title; ?></div>
<!-- Page Navigation end-->

<h2><?php echo $title; ?></h2>

<!-- #featured section start -->
<div id="featured">
    <div>
        <h3 style="margin-bottom:12px;">General information & Population Statistics</h3>
        <p><img src="<?php echo base_url(); ?>images/gampola-map.png" width="190" class="left-align" style="border:5px solid #868593;" alt=""/>You can remove any link to our website from this website template, you're free to use this website template without linking back to us. <br/><br/> If you're having problems editing this website template, then don't hesitate to ask for help on the You can remove any link to our website from this website template, you're free to use this website template without linking back to us.. 	<a href="#">read more</a>
    </div>


</div><!-- #featured section end -->

<!-- .article section Start -->
				<div class="article">

                <!-- Race / Religion / Gender / Age  Start	-->
                <div class="news">
                <div id="searchresult" style="display: none;"></div>
                <div id="defaultresult">

                    <!-- Race Section start -->
                    <div class="section-01 st">
                        <h4>Race [ජන වර්ගය] :</h4>
                        <table id="hor-minimalist-b" summary="">
                            <thead>
                            <tr>
                                <th width="185" scope="col">Category</th>
                                <th width="93" scope="col">Amount</th>
                            </tr>
                            </thead>
                            <tbody>

                            <?php
                                foreach ($population_arr as $population_arr) :
                                    if($population_arr['populationcatdesc'] == "sinhalese")
                                        $sinhalese .= $population_arr['TOTALCOUNT'];
                                    if($population_arr['populationcatdesc'] == "srilankan_tamil")
                                        $srilankan_tamil .= $population_arr['TOTALCOUNT'];
                                    if($population_arr['populationcatdesc'] == "indian_tamil")
                                        $indian_tamil .= $population_arr['TOTALCOUNT'];
                                    if($population_arr['populationcatdesc'] == "muslim")
                                        $muslim .= $population_arr['TOTALCOUNT'];
                                    if($population_arr['populationcatdesc'] == "other_nat")
                                        $other_nat .= $population_arr['TOTALCOUNT'];
                                    if($population_arr['populationcatdesc'] == "buddhist")
                                        $buddhist .= $population_arr['TOTALCOUNT'];
                                    if($population_arr['populationcatdesc'] == "catholic")
                                        $catholic .= $population_arr['TOTALCOUNT'];
                                    if($population_arr['populationcatdesc'] == "islam")
                                        $islam .= $population_arr['TOTALCOUNT'];
                                    if($population_arr['populationcatdesc'] == "hindu")
                                        $hindu .= $population_arr['TOTALCOUNT'];
                                    if($population_arr['populationcatdesc'] == "other_rel")
                                        $other_rel .= $population_arr['TOTALCOUNT'];
                                    if($population_arr['populationcatdesc'] == "male")
                                        $male .= $population_arr['TOTALCOUNT'];
                                    if($population_arr['populationcatdesc'] == "female")
                                        $female .= $population_arr['TOTALCOUNT'];
                                    if($population_arr['populationcatdesc'] == "age_1_16")
                                        $age_1_16 .= $population_arr['TOTALCOUNT'];
                                    if($population_arr['populationcatdesc'] == "age_16_30")
                                        $age_16_30 .= $population_arr['TOTALCOUNT'];
                                    if($population_arr['populationcatdesc'] == "age_30_50")
                                        $age_30_50 .= $population_arr['TOTALCOUNT'];
                                    if($population_arr['populationcatdesc'] == "age_50")
                                        $age_50 .= $population_arr['TOTALCOUNT'];
                                endforeach;
                            ?>

                            <tr>
                                <td>Sinhalese</td>
                                <td><?php echo $sinhalese; ?></td>
                            </tr>
                            <tr>
                                <td>Sri Lankan Tamil</td>
                                <td><?php echo $srilankan_tamil; ?></td>
                            </tr>
                            <tr>
                                <td>Indian Tamil</td>
                                <td><?php echo $indian_tamil; ?></td>
                            </tr>
                            <tr>
                                <td>Muslim</td>
                                <td><?php echo $muslim; ?></td>
                            </tr>
                            <tr>
                                <td>Other</td>
                                <td><?php echo $other_nat; ?></td>
                            </tr>
                            <tr>
                                <td class="td-style01" style="border-bottom:none;" >Total</td>
                                <td class="td-style01" style="border-bottom:none;" >
                                    <?php
                                        $total_nat = $sinhalese + $srilankan_tamil + $indian_tamil + $muslim + $other_nat;
                                        echo $total_nat; // do not delete
                                    ?>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </div><!-- Race Section end -->

                    <!-- Religion Section start -->
                    <div class="section-01">
                        <h4>Religion [ආගම] :</h4>
                        <table id="hor-minimalist-b" summary="">
                            <thead>
                            <tr>
                                <th width="185" scope="col">Category</th>
                                <th width="93" scope="col">Amount</th>
                            </tr>
                            </thead>
                            <tbody>
                            <tr>
                                <td>Buddhist</td>
                                <td><?php echo $buddhist; ?></td>
                            </tr>
                            <tr>
                                <td>Catholic</td>
                                <td><?php echo $catholic; ?></td>
                            </tr>
                            <tr>
                                <td>Hindu</td>
                                <td><?php echo $hindu; ?></td>
                            </tr>
                            <tr>
                                <td>Islam</td>
                                <td><?php echo $islam; ?></td>
                            </tr>
                            <tr>
                                <td>Other</td>
                                <td><?php echo $other_rel; ?></td>
                            </tr>
                            <tr>
                                <td class="td-style01" style="border-bottom:none;" >Total</td>
                                <td class="td-style01" style="border-bottom:none;" >
                                    <?php
                                        $total_rel = $buddhist + $catholic + $hindu + $islam + $other_rel;
                                        echo $total_rel; // do not delete
                                    ?>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </div><!-- Religion Section end -->

                    <!-- Gender Section start -->
                    <div class="section-01 st">
                        <h4>Gender [ස්ත්‍රී/පුරුෂ] :</h4>
                        <table id="hor-minimalist-b" summary="">
                            <thead>
                            <tr>
                                <th width="185" scope="col">Category</th>
                                <th width="93" scope="col">Amount</th>
                            </tr>
                            </thead>
                            <tbody>
                            <tr>
                                <td>Male</td>
                                <td><?php echo $male; ?></td>
                            </tr>
                            <tr>
                                <td>Female</td>
                                <td><?php echo $female; ?></td>
                            </tr>
                            <tr>
                                <td class="td-style01" style="border-bottom:none;" >Total</td>
                                <td class="td-style01" style="border-bottom:none;" >
                                    <?php
                                        $total_gen = $male + $female;
                                        echo $total_gen; // do not delete
                                    ?>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </div><!-- Gender Section end -->

                    <!-- Age Section start -->
                    <div class="section-01">
                        <h4>Age [වයස] :</h4>
                        <table id="hor-minimalist-b" summary="">
                            <thead>
                            <tr>
                                <th width="185" scope="col">Category</th>
                                <th width="93" scope="col">Amount</th>
                            </tr>
                            </thead>
                            <tbody>
                            <tr>
                                <td>1-16</td>
                                <td><?php echo $age_1_16; ?></td>
                            </tr>
                            <tr>
                                <td>16-30</td>
                                <td><?php echo $age_16_30; ?></td>
                            </tr>
                            <tr>
                                <td>30-50</td>
                                <td><?php echo $age_30_50; ?></td>
                            </tr>
                            <tr>
                                <td>50 above</td>
                                <td><?php echo $age_50; ?></td>
                            </tr>
                            <tr>
                                <td class="td-style01" style="border-bottom:none;" >Total</td>
                                <td class="td-style01" style="border-bottom:none;" >
                                    <?php
                                        $total_age = $age_1_16 + $age_16_30 + $age_30_50 + $age_50;
                                        echo $total_age;
                                    ?>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </div><!-- Age Section end -->

                </div><!-- Race / Religion / Gender / Age  End	-->
                </div>
		
		<?php
			/*array_push($bar_chart_rows_arr, array('c' => array(
                                                            array('v' => $task_submissions_arr[$i]['name']), 
                                                            array('v' => $task_submissions_arr[$i]['auto_grading_marks']), 
                                                            array('v' => $task_submissions_arr[$i]['manual_grading_marks'])))  );

				*/

				//$columnchart_cols_arr = array('Religion','buddhist','catholic','islam','hindu','other');
				for($i=0; $i<count($population_arr); $i++){
					if($population_arr[$i]['populationcatdesc'] == "buddhist")
                                        $buddhist = $population_arr[$i]['TOTALCOUNT'];
					if($population_arr[$i]['populationcatdesc'] == "catholic")
					$catholic = $population_arr[$i]['TOTALCOUNT'];
					if($population_arr[$i]['populationcatdesc'] == "islam")
					$islam = $population_arr[$i]['TOTALCOUNT'];
					if($population_arr[$i]['populationcatdesc'] == "hindu")
					$hindu = $population_arr[$i]['TOTALCOUNT'];
					if($population_arr[$i]['populationcatdesc'] == "other_rel")
					$other_rel = $population_arr[$i]['TOTALCOUNT'];	
					if($population_arr['populationcatdesc'] == "sinhalese")
                                        $sinhalese = $population_arr['TOTALCOUNT'];
					if($population_arr['populationcatdesc'] == "srilankan_tamil")
					$srilankan_tamil = $population_arr['TOTALCOUNT'];
					if($population_arr['populationcatdesc'] == "indian_tamil")
					$indian_tamil = $population_arr['TOTALCOUNT'];
					if($population_arr['populationcatdesc'] == "muslim")
					$muslim = $population_arr['TOTALCOUNT'];
					if($population_arr['populationcatdesc'] == "other_nat")
					$other_nat = $population_arr['TOTALCOUNT'];				
				}
		?>
		
		<script type="text/javascript">
			google.load("visualization", "1", {packages:["corechart"]});
			google.setOnLoadCallback(drawChart);
			function drawChart() {
			/*var data = google.visualization.arrayToDataTable([
			  ['Religion', 'Buddhist', 'Catholic', 'Islam', 'Hindu', 'Other'],
			  ['Buddhist',  <?php echo $buddhist; ?>, 0, 0, 0, 0],
			  ['Catholic',  0, <?php echo $catholic; ?>, 0, 0, 0],
			  ['Islam', 0, 0, <?php echo $islam; ?>, 0, 0],
			  ['Hindu', 0, 0, 0, <?php echo $hindu; ?>, 0],
			  ['Other', 0, 0, 0, 0, <?php echo $other_rel; ?>]
			]);*/

var data = new google.visualization.DataTable();
    data.addColumn('string', 'Religion');
    data.addColumn('number', 'Stats');
    data.addRows([
      ['Buddhist',<?php echo $buddhist; ?>],
      ['Catholic',<?php echo $catholic; ?>],
      ['Islam',<?php echo $islam; ?>],
      ['Hindu',<?php echo $hindu; ?>],
      ['Other',<?php echo $other_rel; ?>],
    ]);

			
			var options = {
			  title: 'Religion [ආගම]',
			  legend: 'none',
			  colors: ['blue']			
			};



			var chart = new google.visualization.ColumnChart(document.getElementById('chart_religion'));
			chart.draw(data, options);
			}
		</script>

		<script type="text/javascript">
			google.load("visualization", "1.0", {packages:["corechart"]});
			google.setOnLoadCallback(drawChart);
			function drawChart() {
				var data = new google.visualization.DataTable();
				data.addColumn('string', 'Race');
				data.addColumn('number', 'Stats');
				data.addRows([
					['Sinhalese',<?php echo $sinhalese; ?>],
					['Sri Lankan Tamil',<?php echo $srilankan_tamil; ?>],
					['Indian Tamil',<?php echo $indian_tamil; ?>],
					['Muslim',<?php echo $muslim; ?>],
					['Other',<?php echo $other_nat; ?>],
				]);
			
			
				//var formatter = new google.visualization.BarFormat({width: 20});
  				//formatter.format(data, 1); // Apply formatter to second column

				var options = {
					title: 'Race [ජන වර්ගය]',
					legend: 'none',
			  		colors: ['green']
				};

				var chart1 = new google.visualization.ColumnChart(document.getElementById('chart_race'));
				chart1.draw(data, options);
			}
		</script>
		
                <div class="section odd">
                    <div>
                        <!-- Area Sections Tabs Start -->
                        <h2>Statistics</h2>
                        <div id="chart_religion" class="stat_charts" style="width: 600px; height: 300px;"></div>
<div id="chart_race" class="stat_charts" style="width: 600px; height: 300px;"></div>
                        <!-- Area Sections Tabs End -->


                    </div>
                </div>
